<?php

class unitreeController {
	
	function __construct() {
	}
	
	public function render( $tplname ) {
		$block = App::me()->viewPath. DIRECTORY_SEPARATOR .'unitree'. DIRECTORY_SEPARATOR .$tplname;
		$tpl = App::me()->tpl;
		$tpl->display($block.'.tpl');
	}
	
	public function index() {		
		if( !Tools::isAjax() ) return;
		$this->render('form');		
	}	

	public function gettree() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new unitree;
		$data = $model->gettree();
		echo $data;
	}
	
	public function insert() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new unitree;
		$data = $model->insert();
		echo json_encode( $data );
	}
	
	public function update() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new unitree;
		$data = $model->update();
		echo json_encode( $data );
	}
	
	public function delete() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new unitree;
		$data = $model->delete();
		echo json_encode( $data );
	}

	public function move() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new unitree;
		$data = $model->move();
		echo json_encode( $data );
	}

	public function jsload() {		
		if( !Tools::isAjax() ) return;
		App::me()->js_load('unitree.js');
	}	
	
}
?>